/**
 * Created by Administrator on 2018/9/30.
 */
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);// {'title': '工作台', 'path': '/work', 'isCurrent': true,'name':"1"}
export default new Vuex.Store({
  state : {
    tagNavList: [

    ],
    tagCurrent: '/work',
    show:false
  },
  mutations : {
    changeTag (state, current) {
      state.tagCurrent = current;
    },
    changeShow (state, current) {
      state.show = current;
    },
    openPage (state, tagItem={}) {
      var isNew = true;
      state.tagNavList.forEach(function(item){
        if(item.title === tagItem.title){
          item.isCurrent = true;
          isNew = false;
        }else{
          item.isCurrent = false;
        }
      })
      if(isNew){
        tagItem.isCurrent = true;
        state.tagNavList.push(tagItem);
        // window.sessionStorage.setItem('tag',JSON.stringify(state.tagNavList))
      }
      // console.log(state.tagNavList,'tagNavList');
    },
    closePage (state, newList) {
      state.tagNavList = newList;
      // window.sessionStorage.setItem('tag',JSON.stringify(state.tagNavList))
    },
    getMenuLists (state, list) {
      // console.log(state)
    }
  }
})
